package com.yunyao.dao.service.bamu.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunyao.common.constant.enums.DataDeletedStatus;
import com.yunyao.dao.mapper.BamuMaterialCategoryMapper;
import com.yunyao.dao.model.BamuMaterialCategory;
import com.yunyao.dao.service.bamu.IBamuMaterialCategoryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 材料分类 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuMaterialCategoryServiceImpl extends ServiceImpl<BamuMaterialCategoryMapper, BamuMaterialCategory> implements IBamuMaterialCategoryService {

    @Override
    public long countById(String id) {
        if (StringUtils.isBlank(id)){
            return 0L;
        }
        // 构建查询条件
        LambdaQueryWrapper<BamuMaterialCategory> queryWrapper =
                new LambdaQueryWrapper<BamuMaterialCategory>()
                        .eq(BamuMaterialCategory::getParentId, id)
                        .eq(BamuMaterialCategory::getIsDeleted, DataDeletedStatus.NO.getType());
        return count(queryWrapper);
    }
}
